package me.khrystal.cleanmaster.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * usage:
 * author: kHRYSTAL
 * create time: 16/9/14
 * update time:
 * email: 723526676@qq.com
 */
public class T {

    private static Toast toast;

    public static void showShort(Context context, CharSequence message) {
        if (null == toast)
            toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
        else
            toast.setText(message);
        toast.show();
    }

    public static void showShort(Context context, int message) {
        if (null == toast)
            toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
        else
            toast.setText(message);
        toast.show();
    }

    public static void showLong(Context context, CharSequence message) {
        if (null == toast)
            toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
        else
            toast.setText(message);
        toast.show();
    }

    public static void showLong(Context context, int message) {
        if (null == toast)
            toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
        else
            toast.setText(message);
        toast.show();
    }

    public static void show(Context context, CharSequence message, int duration) {
        if (null == toast) {
            toast = Toast.makeText(context, message, duration);
        } else
            toast.setText(message);
        toast.show();
    }

    public static void show(Context context, int message, int duration) {
        if (null == toast) {
            toast = Toast.makeText(context, message, duration);
        } else
            toast.setText(message);
        toast.show();
    }

    public static void hideToast() {
        if (null != toast)
            toast.cancel();
    }

}
